﻿using Missbot.Common;
using MongoDB.Driver;

namespace MissRobot.Migrator.SourceMongo
{
    public class SourceMongContext : ISingleton
    {
        private readonly IMongoDatabase _Database;

        public SourceMongContext()
        {
            var mongoConnStr = Configger<MigrateConfig>.AIConfig.SourceMongoConnStr;
            var mongoDbName  = Configger<MigrateConfig>.AIConfig.SourceMongoDbName;

            var client = new MongoClient(mongoConnStr);
            _Database = client.GetDatabase(mongoDbName);
        }

        public IMongoCollection<T> Collection<T>()
        {
            return _Database.GetCollection<T>(typeof(T).Name);
        }
    }
}